import { isObject } from "./utils";
import { createElement, createText } from "./vdom/index";

// import 
export function renderMixin(Vue) {


  Vue.prototype._c = function () {// 创建div等元素节点
    const vm = this;
    return createElement(vm, ...arguments)
  }
  Vue.prototype._v = function (text) { // 创建文本的虚拟节点， 虚拟节点为对象{ }
    const vm = this;
    return createText(vm, text)
  }
  Vue.prototype._s = function (val) {// 模板变量数据替换{{arr}} =>[11]
    if (isObject(val)) return JSON.stringify(val);
    return val;
  }


  Vue.prototype._render = function () {
    // render函数执行，生成虚拟dom
    const vm = this;
    let { render } = vm.$options;
    let vnode = render.call(vm);
    return vnode
  }

}